home *** CD-ROM | disk | FTP | other *** search
- Path: news.wyoming.com!usenet
- From: dcromley@wyoming.com (Dave Cromley)
- Newsgroups: comp.lang.c++,comp.os.msdos.programmer
- Subject: Re: Function Pointers In C++
- Date: 11 Feb 1996 18:34:02 GMT
- Organization: wyoming.com LLC
- Message-ID: <4flcqq$35n@horn.wyoming.com>
- NNTP-Posting-Host: cys-cap-4.wyoming.com
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.99.2
-
- Nathan wrote:
-
- >I have a class which contains function pointers. ..
- >I seem to be having troubles setting these pointers? ..
-
- I hope this helps.
- I don't understand all I know about this.
-
- Dave C.
-
- #include <iostream.h>
- typedef char byte;
-
- void func1(int); // function returning void
- void far *func2(int); // function returning pointer to void
-
- class c_a {
- public: byte far (*Func)(); // pointer to function returning byte
- c_a::c_a();
- } ;
-
- byte b1;
-
- void main() {
- c_a c_a1;
- cout << "Hello, world.\n";
- }
-
- c_a::c_a() {
- Func = (byte far (*)())func1; // or
- Func = (byte far (*)())func2(9); // I think func2 is your case
- }
-
- void func1(int p) { // function returning void
- }
-
- void far *func2(int p) { // function returning pointer to void
- return (void far *) &b1;
- }
-
-
-